#pragma once

#include <safeque.hxx>
#include <mytypes.h>
#include <mythread.hxx>
#include <string>

using namespace std;

class FileLog;
typedef struct tagBridgeMsg tBridgeMsg;

class BridgeConn : public Thread
{
    public:
        BridgeConn(const string& host, tUInt32 port, FileLog* filelog = NULL);
        ~BridgeConn();

        void Shutdown(void);

        void SendMsg(tBridgeMsg* bmsg);
        tBridgeMsg* GetMsg(void);

    protected:
        
        virtual void Execute(Thread::Arg);

    private:

        const string _host;
        tUInt32 _port;

        SafeQue<tBridgeMsg*> _in_que;
        SafeQue<tBridgeMsg*> _out_que;
        
        bool _shutdown_requested;
        FileLog* _filelog;
};
